package com.family.web.controller.pedigree;


import com.family.common.annotation.Log;
import com.family.common.core.controller.BaseController;
import com.family.common.core.domain.AjaxResult;
import com.family.common.enums.BusinessType;
import com.family.pedigree.domain.FamilyTreeBrief;
import com.family.system.service.IFamilyTreeBriefService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 家族简介描述表 前端控制器
 * </p>
 *
 * @author forever
 * @since 2025-01-03
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/family/brief")
public class FamilyTreeBriefController extends BaseController {

    private final IFamilyTreeBriefService familyTreeBriefService;

    //@Log(title = "添加家族简介", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FamilyTreeBrief brief) {
        familyTreeBriefService.add(brief);
        return AjaxResult.success();
    }

    //@Log(title = "修改家族简介", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FamilyTreeBrief brief) {
        familyTreeBriefService.edit(brief);
        return AjaxResult.success();
    }

    //@Log(title = "删除家族简介", businessType = BusinessType.DELETE)
    @DeleteMapping("/{id}")
    public AjaxResult delById(@PathVariable Long id) {
        familyTreeBriefService.delById(id);
        return AjaxResult.success();
    }

    @GetMapping("/list")
    public AjaxResult getList(FamilyTreeBrief brief) {
        return AjaxResult.success(familyTreeBriefService.getList(brief));
    }
}
